sql = '''select
TO_CHAR(SUBMIT_TIME,'yyyy-mm') 日期,
sum(1) 总条数,
SUM(CASE WHEN status='2' THEN 1 ELSE 0 END) AS 审计中2,
SUM(CASE WHEN status='3' THEN 1 ELSE 0 END) AS 提交成功3,
SUM(CASE WHEN status='4' THEN 1 ELSE 0 END) AS 提交失败4,
SUM(CASE WHEN status='5' THEN 1 ELSE 0 END) AS 应答成功5,
SUM(CASE WHEN status='6' THEN 1 ELSE 0 END) AS 应答失败6,
SUM(CASE WHEN status='7' THEN 1 ELSE 0 END) AS 状态报告成功7,
SUM(CASE WHEN status='8' THEN 1 ELSE 0 END) AS 状态报告失败8,
SUM(CASE WHEN status='11' THEN 1 ELSE 0 END) AS 费用不足11,
SUM(CASE WHEN status='12' THEN 1 ELSE 0 END) AS 黑名单12,
SUM(CASE WHEN status='13' THEN 1 ELSE 0 END) AS 非法关键字13,
SUM(CASE WHEN status='14' THEN 1 ELSE 0 END) AS 审计未通过14,
SUM(CASE WHEN status='15' THEN 1 ELSE 0 END) AS 其他15,
SUM(CASE WHEN status='16' THEN 1 ELSE 0 END) AS 白名单16,
SUM(CASE WHEN status='17' THEN 1 ELSE 0 END) AS 审计用户17,
SUM(CASE WHEN status='18' THEN 1 ELSE 0 END) AS 无效的短信长度18,
SUM(CASE WHEN status='19' THEN 1 ELSE 0 END) AS 无效签名19
from CMGW_MT_BAK
where SUBMIT_TIME>=to_date('2021-04-01 00:00:00','yyyy-mm-dd hh24:mi:ss')
and SUBMIT_TIME<to_date('2021-04-30 23:59:59','yyyy-mm-dd hh24:mi:ss')
and CUST_NO IN('1000055')
group by TO_CHAR(SUBMIT_TIME,'yyyy-mm')
order by 1 desc'''

import cx_Oracle

conn = cx_Oracle.connect('cmgw/g9%iX3oA#stjsGQ#@192.168.6.38:1521/gstgate')
cur = conn.cursor()
cur.execute(sql)
print(cur.fetchall())

